<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>店铺</title>
    <style>
        div {
            position: absolute;
            top: 30%;
            left: 50%;
            transform: translate(-50%, -50%);
            text-align: center;
        }

        table, tr, th, td {
            border: 1px solid #5fbdcb;
        }

        table {
            border-collapse: collapse;
        }
    </style>
</head>
<body>
<div>
    <table></table>
    <br>
    <a href="AuditStore.jsp">待审核的店铺</a>
    <a href="ManagerPage.jsp">返回</a>
</div>
<script src="https://lib.sinaapp.com/js/jquery/2.0.2/jquery-2.0.2.min.js"></script>
<script>
    $(function () {
        $.ajax({
            url: "http://localhost:8080/store.do",
            type: "post",
            data: {
                method: 'managerStore',
            },
            dataType: "text",
            success: function (data) {
                let table = document.querySelector('table');
                let parse = JSON.parse(data);
                if (parse.length === 0) {
                    alert("无店铺")
                }
                for (let i = 0; i < parse.length; i++) {
                    let tr = document.createElement('tr');
                    table.appendChild(tr);
                    let th1 = document.createElement('th');
                    tr.appendChild(th1);
                    th1.innerText = '店铺名';
                    let td1 = document.createElement('td');
                    tr.appendChild(td1);
                    td1.innerText = parse[i].storeName;
                    let th2 = document.createElement('th');
                    tr.appendChild(th2);
                    th2.innerText = '菜品数';
                    let td2 = document.createElement('td');
                    tr.appendChild(td2);
                    td2.innerText = parse[i].dishNum;
                    let th3 = document.createElement('th');
                    tr.appendChild(th3);
                    th3.innerText = '简介';
                    let td3 = document.createElement('td');
                    tr.appendChild(td3);
                    td3.innerText = parse[i].introduce;
                    let th4 = document.createElement('th');
                    tr.appendChild(th4);
                    th4.innerText = '完成订单';
                    let td4 = document.createElement('td');
                    tr.appendChild(td4);
                    td4.innerText = parse[i].processOrderNum;
                    if (parse[i].status===1){
                        let td5 = document.createElement('td');
                        tr.appendChild(td5);
                        let a = document.createElement('a');
                        a.innerText = '下线';
                        a.href = 'downStore.jsp?storeId=' + parse[i].storeId;
                        td5.appendChild(a);
                    }
                }
            }
        })
    })
</script>
</body>
</html>
